package com.tsxy.config;

import com.tsxy.common.intercepter.JwtIntercepter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class IntercepterConfiger implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getJwtIntercepter())
                .addPathPatterns("/**")         //拦截所有的请求，判断是否合法，判断是否进行登录
                .excludePathPatterns("/user/login","/user/register","/**/export","/**/import","/file/**","/swagger-ui.html",
                        "/index");
    }

    @Bean
    public JwtIntercepter getJwtIntercepter(){
        return new JwtIntercepter();
    }
}
